package com.example.statistics.ui.port

import com.example.statistics.bean.ColdStorageBean
import com.example.statistics.bean.DefineInputBean
import com.example.statistics.bean.ExchangeRate
import com.example.statistics.common.BaseInputActivity
import com.example.statistics.ex.orEmpty
import com.example.statistics.net.UrlConfig
import com.example.statistics.utils.Constants
import com.example.statistics.weight.TextProcessingView

/**
 * 汇率新增
 */
class StorageAddActivity : BaseInputActivity<ColdStorageBean>() {

    var data: ColdStorageBean? = null

    override val title: String
        get() = "港口冷库"

    override val url: String
        get() = if (data == null) UrlConfig.PURCHASE_STORAGE_ADD else UrlConfig.PURCHASE_STORAGE_UPDATE

    override val inputDataList: List<DefineInputBean>
        get() = listOf(
            DefineInputBean("城市：", "city", TextProcessingView.STYLE_SELECTOR,
                labelValue = data?.city.orEmpty(), isNull = false,
                singleDialog = Pair(listOf("上海", "天津", "盐田")) { str, _ ->
                    this.contentText = str
                }),
            DefineInputBean(
                "冷库：", "storage", TextProcessingView.STYLE_INPUT,
                labelValue = data?.storage.orEmpty(), isNull = false
            ),
            DefineInputBean(
                "单价：", "price", TextProcessingView.STYLE_INPUT_FLOAT,
                labelValue = data?.price?.toString()
            ),
            DefineInputBean(
                "位置：", "position", TextProcessingView.STYLE_INPUT,
                labelValue = data?.position.orEmpty()
            ),
            DefineInputBean(
                "代理：", "agent", TextProcessingView.STYLE_INPUT,
                labelValue = data?.agent.orEmpty()
            )
        )


    override fun initialize() {
        super.initialize()
        data = intent.getSerializableExtra(Constants.DATA) as ColdStorageBean?
        if (data != null) {
            extentParams.add("id" to data?.id.orEmpty())
        }
    }
}